package com.softserveinc.interactive_board.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.softserveinc.interactive_board.dao.UserDAO;
import com.softserveinc.interactive_board.domain.User;
import com.softserveinc.interactive_board.domain.UserType;

@Service
public class UserServiceImpl implements UserService {
	
	
	@Transactional
	public List<UserType> getUserTypes() {
		return userDAO.getUserTypes();
	}
	
	
	@Transactional
	public List<UserType> getRegistratebleUserTypes() {
		return userDAO.getRegistratebleUserTypes();
	}
	
	
	@Transactional
	public List<User> getUsers() {
		return userDAO.getUsers();
	}
	
	@Transactional
	public List<User> getUsersByType(int typeId) {
		return userDAO.getUsersByType(typeId);
	}
	
	@Transactional
	public User getUser(Long id) {
		return userDAO.getUser(id);
	}
	
	@Transactional
	public User getUser(String login) {
		return userDAO.getUser(login);
	} // it's too
	
	@Transactional
	public boolean addUser(final User user) {
		return this.userDAO.addUser(user);
	}
	

	@Transactional
	public boolean updateUser(User user) {
		return this.userDAO.updateUser(user);
	}
	
	
	@Transactional
	public void deleteUser(final Long userId) {
		this.userDAO.deleteUser(userId);
	}
	
	@Transactional
	public void deleteUsers(List<User> list) {
		this.userDAO.deleteUsers(list);
	}

	
	protected UserDAO userDAO;

	@Autowired
	@Qualifier("userDAOImpl")
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
}
